<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script src="<?=Q::ini('custom_system/base_url');?>js/validator.js"></script>
<script type="text/javascript">
$(function(){
	$("#dialog_create_shop").dialog({autoOpen: false, modal: true, height: 250, width: 550});
	$(".create_shop").click(function(){
		$("#dialog_create_shop").dialog("open");
	});
	$(".bind").colorbox({width:"43%", height:"80%", iframe:true});
});
</script>
<fieldset><legend>查询条件</legend>
<form method="get">
<? include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
<tr>
	<th>所属平台</th>
	<td>
		<select name="platform">
			<option value="">请选择...</option>
			<?foreach ($platform as $p):?>
			<option value="<?=$p?>" <?=isset($_GET['platform']) && $_GET['platform'] == $p ? 'selected=selected' : ''?>><?=$p?></option>
			<?endforeach;?>
		</select>
	</td>
</tr>
<tr>
	<th>状态</th>
	<td>
		<label><input type="checkbox" name="status[1]" value="1" <?=isset($_GET['status']) && in_array(1, $_GET['status']) ? 'checked=checked' : ''?>/>上线</label>&nbsp;
		<label><input type="checkbox" name="status[0]" value="0" <?=isset($_GET['status']) && in_array(0, $_GET['status']) ? 'checked=checked' : ''?>/>下线</label>
	</td>
</tr>
<tr>
	<th></th>
	<td><input type="submit" class="button" value="查询" /></td>
</tr>
</table>
</form>
</fieldset>
<a href="javascript: void(0)" class="create_shop">添加新店铺</a>
<table width="100%" class="list_table">
<tr>
	<th>编号</th>
	<th>店铺/网站</th>
	<th>平台</th>
	<th>状态</th>
	<th>店铺管理</th>
</tr>
<? foreach($shop as $s):?>
<tr>
	<td scope="row"><?=$s['id'];?></td>
	<td><?=$s['name']?$s['name']:'&nbsp;';?></td>
	<td><?=$s['platform']?$s['platform']:'&nbsp;';?></td>
	<td><?=($s['status']==1) ? '上线' : '下线'?></td>
	<td><a class="bind" href="<?=url('Setting::Basic/ShopAllotUser', array('shop_id' => $s['id']))?>">绑定用户</a></td>
</tr>
<? endforeach;?>
</table>
<?=$page;?>
<div id="dialog_create_shop" title="添加新店铺">
<form action="<?=url('Setting::Basic/ShopCreateSave')?>" method="post" onSubmit="return Validator.Validate(this,3)">
<table class="form_table">
<tr>
	<th>店铺/网站名称</th>
	<td><input type="text" name="name" id="name" size="40" value="<?=isset($shop['name'])?$shop['name']:'';?>" dataType="Custom" regexp="^(\S)" msg="店铺名称不能为空"/> <span class="red">*</span> </td>
</tr>
<tr>
	<th>所属平台</th>
	<td>
		<select name="platform" dataType="Require" msg="请选择所属平台">
			<option value="">请选择...</option>
			<?foreach ($platform as $p):?>
			<option value="<?=$p?>"><?=$p?></option>
			<?endforeach;?>
		</select> <span class="red">*</span>
	</td>
</tr>
<tr>
	<th>状态</th>
	<td><select name="status"><option value="1">上线</option><option value="0">下线</option></select></td>
</tr>
<tr>
	<th><input type="hidden" name="<?=Q::ini('unique_token_name');?>" value="<?=Helper_BSS_Normal::genToken();?>"/></th>
	<td><input type="submit" class="button" value="创建" /></td>
</tr>
</table>
</form>
</div>
<?php $this->_endblock(); ?>